﻿using System;
using System.Collections;

namespace WFIM.Framework.Parellel
{
  /// <include file='XMLCodeDocumentation.xml' path='documentation/item[@name="T_PropertybagState"]/*' />
  public class PropertybagState : ParallelState
  {
    //-----------------------------------------------------------------------
    // FIELDS
    //-----------------------------------------------------------------------
    private Hashtable propertyBag   = new Hashtable();

    //-----------------------------------------------------------------------
    // CONSTRUCTORS
    //-----------------------------------------------------------------------

    //-----------------------------------------------------------------------
    // METHODS
    //-----------------------------------------------------------------------
    /// <summary>Set (or overwrite) a property in the propertybag.</summary>
    /// <param name="_key">The name of the property.</param>
    /// <param name="_value">The (new) value of the property.</param>
    public void setProperty(string _key, object _value)
    {
      propertyBag[_key] = _value;
    }

    //-----------------------------------------------------------------------
    /// <summary>Reads a property from the propertybag.</summary>
    /// <param name="_key">The name of the property.</param>
    /// <returns>The value of the property.</returns>
    public object getProperty(string _key)
    {
      return propertyBag[_key];
    }

    //-----------------------------------------------------------------------
    /// <summary>Reads a property from the propertybag.</summary>
    /// <param name="_key">The name of the property.</param>
    /// <returns>The value of the property casted to a <see cref="bool"/>.</returns>
    public bool getPropertyBool(string _key)
    {
      return (bool)propertyBag[_key];
    }

    //-----------------------------------------------------------------------
    /// <summary>Reads a property from the propertybag.</summary>
    /// <param name="_key">The name of the property.</param>
    /// <returns>The value of the property casted to an <see cref="int"/>.</returns>
    public int getPropertyInt(string _key)
    {
      return (int)propertyBag[_key];
    }

    //-----------------------------------------------------------------------
    /// <summary>Reads a property from the propertybag.</summary>
    /// <param name="_key">The name of the property.</param>
    /// <returns>The value of the property casted to a <see cref="string"/>.</returns>
    public string getPropertyString(string _key)
    {
      return (string)propertyBag[_key];
    }

    //-----------------------------------------------------------------------
  }
}
